<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The Judy class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="judy.resources.html">资源类型</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="judy.bycount.html">Judy::byCount</a></div>
 <div class="up"><a href="book.judy.html">Judy</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.judy" class="reference">

 <h1 class="title">The <a href="class.judy.html" class="classname">Judy</a> class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL judy &gt;= 0.1.1)</p>


  <div class="section" id="judy.intro">
   <h2 class="title">简介</h2>
   <p class="para">
The Judy class implements the <a href="class.arrayaccess.html" class="link">ArrayAccess</a> 
interface and the <a href="class.iterator.html" class="link">Iterator</a> interface. 
This class, once instantiated, can be accessed like a <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> 
<a href="book.array.html" class="link">array</a>.
   </p>
   <p class="para" id="judy.types">
A PHP Judy object (or Judy Array) can be one of the following type :
<ul class="simplelist">
 <li class="member"><a href="class.judy.html#judy.constants.bitset" class="link">Judy::BITSET</a></li>
 <li class="member"><a href="class.judy.html#judy.constants.int-to-int" class="link">Judy::INT_TO_INT</a></li>
 <li class="member"><a href="class.judy.html#judy.constants.int-to-mixed" class="link">Judy::INT_TO_MIXED</a></li>
 <li class="member"><a href="class.judy.html#judy.constants.string-to-int" class="link">Judy::STRING_TO_INT</a></li>
 <li class="member"><a href="class.judy.html#judy.constants.string-to-mixed" class="link">Judy::STRING_TO_MIXED</a></li>
</ul>
   </p>
   <p class="para">
    <div class="example" id="example-3672">
      <div class="info"><p><strong>Example #1 Judy array example</strong></p></div>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$judy&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Judy</span><span style="color: #007700">(</span><span style="color: #0000BB">Judy</span><span style="color: #007700">::</span><span style="color: #0000BB">INT_TO_MIXED</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$judy</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">"one"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$judy</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]&nbsp;=&nbsp;array(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'b'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'c'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$judy</span><span style="color: #007700">[</span><span style="color: #0000BB">3</span><span style="color: #007700">]&nbsp;=&nbsp;new&nbsp;</span><span style="color: #0000BB">Judy</span><span style="color: #007700">(</span><span style="color: #0000BB">Judy</span><span style="color: #007700">::</span><span style="color: #0000BB">BITSET</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

    </div>
   </p>
  </div>


  <div class="section" id="judy.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">Judy</strong>
     </span>
     
     <span class="oointerface">implements 
      <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>
     </span>
     <span class="oointerface">, 
      <span class="interfacename"><strong class="interfacename">Iterator</strong></span>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.judy.html#judy.constants.bitset"><var class="varname">BITSET</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.judy.html#judy.constants.int-to-int"><var class="varname">INT_TO_INT</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.judy.html#judy.constants.int-to-mixed"><var class="varname">INT_TO_MIXED</var></a></var>
     <span class="initializer"> = 3</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.judy.html#judy.constants.string-to-int"><var class="varname">STRING_TO_INT</var></a></var>
     <span class="initializer"> = 4</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.judy.html#judy.constants.string-to-mixed"><var class="varname">STRING_TO_MIXED</var></a></var>
     <span class="initializer"> = 5</span>
    ;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.bycount.html" class="methodname">byCount</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$nth_index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="judy.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$judy_type</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.count.html" class="methodname">count</a></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$index_start</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$index_end</code><span class="initializer"> = -1</span></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="judy.destruct.html" class="methodname">__destruct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">mixed</span><span class="methodname"><a href="judy.first.html" class="methodname">first</a></span>
    ([ <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.firstempty.html" class="methodname">firstEmpty</a></span>
    ([ <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code><span class="initializer"> = 0</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.free.html" class="methodname">free</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.gettype.html" class="methodname">getType</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="judy.last.html" class="methodname">last</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.lastempty.html" class="methodname">lastEmpty</a></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$index</code><span class="initializer"> = -1</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.memoryusage.html" class="methodname">memoryUsage</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">mixed</span><span class="methodname"><a href="judy.next.html" class="methodname">next</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.nextempty.html" class="methodname">nextEmpty</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="judy.offsetexists.html" class="methodname">offsetExists</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">mixed</span><span class="methodname"><a href="judy.offsetget.html" class="methodname">offsetGet</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="judy.offsetset.html" class="methodname">offsetSet</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span><span class="methodname"><a href="judy.offsetunset.html" class="methodname">offsetUnset</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">mixed</span><span class="methodname"><a href="judy.prev.html" class="methodname">prev</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="judy.prevempty.html" class="methodname">prevEmpty</a></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="judy.size.html" class="methodname">size</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>


  </div>
  

  <div class="section" id="judy.constants">
   <h2 class="title">预定义常量</h2>
   <dl>


    
     <dt id="judy.constants.bitset"><strong><code>Judy::BITSET</code></strong></dt>

     <dd>

      <p class="para">Define the Judy Array as a Bitset with keys as Integer and Values as a Boolean</p>
     </dd>

    

    
     <dt id="judy.constants.int-to-int"><strong><code>Judy::INT_TO_INT</code></strong></dt>

     <dd>

      <p class="para">Define the Judy Array with key/values as Integer, and Integer only.</p>
     </dd>

    

    
     <dt id="judy.constants.int-to-mixed"><strong><code>Judy::INT_TO_MIXED</code></strong></dt>

     <dd>

      <p class="para">Define the Judy Array with keys as Integer and Values of any type.</p>
     </dd>

    

    
     <dt id="judy.constants.string-to-int"><strong><code>Judy::STRING_TO_INT</code></strong></dt>

     <dd>

      <p class="para">Define the Judy Array with keys as a String and Values as Integer, and Integer only.</p>
     </dd>

    

    
     <dt id="judy.constants.string-to-mixed"><strong><code>Judy::STRING_TO_MIXED</code></strong></dt>

     <dd>

      <p class="para">Define the Judy Array with keys as a String and Values of any type.</p>
     </dd>

    

   </dl>

  </div>



 </div>

 













































































































































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="judy.bycount.html">Judy::byCount</a> — Locate the Nth index present in the Judy array</li><li><a href="judy.construct.html">Judy::__construct</a> — Construct a new Judy object</li><li><a href="judy.count.html">Judy::count</a> — Count the number of elements in the Judy array</li><li><a href="judy.destruct.html">Judy::__destruct</a> — Destruct a Judy object</li><li><a href="judy.first.html">Judy::first</a> — Search for the first index in the Judy array</li><li><a href="judy.firstempty.html">Judy::firstEmpty</a> — Search for the first absent index in the Judy array</li><li><a href="judy.free.html">Judy::free</a> — Free the entire Judy array</li><li><a href="judy.gettype.html">Judy::getType</a> — Return the type of the current Judy array</li><li><a href="judy.last.html">Judy::last</a> — Search for the last index in the Judy array</li><li><a href="judy.lastempty.html">Judy::lastEmpty</a> — Search for the last absent index in the Judy array</li><li><a href="judy.memoryusage.html">Judy::memoryUsage</a> — Return the memory used by the Judy array</li><li><a href="judy.next.html">Judy::next</a> — Search for the next index in the Judy array</li><li><a href="judy.nextempty.html">Judy::nextEmpty</a> — Search for the next absent index in the Judy array</li><li><a href="judy.offsetexists.html">Judy::offsetExists</a> — Whether a offset exists</li><li><a href="judy.offsetget.html">Judy::offsetGet</a> — Offset to retrieve</li><li><a href="judy.offsetset.html">Judy::offsetSet</a> — Offset to set</li><li><a href="judy.offsetunset.html">Judy::offsetUnset</a> — Offset to unset</li><li><a href="judy.prev.html">Judy::prev</a> — Search for the previous index in the Judy array</li><li><a href="judy.prevempty.html">Judy::prevEmpty</a> — Search for the previous absent index in the Judy array</li><li><a href="judy.size.html">Judy::size</a> — Return the size of the current Judy array</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="judy.resources.html">资源类型</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="judy.bycount.html">Judy::byCount</a></div>
 <div class="up"><a href="book.judy.html">Judy</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
